home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 1
/
Precision Software Applications Silver Collection Volume One (PSM) (1993).iso
/
windows
/
games
/
blast.arj
/
BLAST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-08-15
|
3KB
|
117 lines
/*** Include files needed for definitions, declarations, etc. ***/
#include <windows.h> /* Required for all Windows programs */
#include <stdlib.h>
/*** Forward declare functions ***/
long FAR PASCAL WndProc (HWND, unsigned, WORD, LONG);
HANDLE hInst;
int PASCAL WinMain (hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
HANDLE hInstance, hPrevInstance;
LPSTR lpszCmdLine;
int nCmdShow;
{
HWND hWnd;
MSG msg;
WNDCLASS wndclass;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor (hInstance, IDC_ARROW);
wndclass.hbrBackground = GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "Blast";
if (!RegisterClass (&wndclass) )
return FALSE;
}
else
return FALSE;
hInst=hInstance;
hWnd = CreateWindow ("Blast", "Blast", WS_OVERLAPPEDWINDOW, 0, 0,
0,0, NULL, NULL, hInstance, NULL);
if(!SetTimer(hWnd, 1, 50, NULL))
{
MessageBox(hWnd, "Too many clocks or timers!", "Error",
MB_ICONEXCLAMATION | MB_OK);
return FALSE;
}
while (GetMessage(&msg, NULL, 0,0 ))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
long FAR PASCAL WndProc (hWnd, iMessage, wParam, lParam)
HWND hWnd;
unsigned iMessage;
WORD wParam;
LONG lParam;
{
static HANDLE hBitmap;
BITMAP bm;
HDC hDC,hMemDC;
short nRand, nIndex;
long xStart, yStart;
char szJunk[40];
switch (iMessage)
{
case WM_TIMER:
if(rand() < 1500)
{
OpenSound();
SetVoiceQueueSize(1, 1000);
SetVoiceAccent(1, 220, 20, S_NORMAL, 0);
for (nIndex=84; nIndex > 0; nIndex -=1 )
SetVoiceNote(1, nIndex, 250, 0);
StartSound();
hBitmap=LoadBitmap(hInst, "Blast");
GetObject(hBitmap, sizeof(BITMAP), (LPSTR) &bm);
hDC=CreateDC("DISPLAY", NULL, NULL, NULL);
hMemDC=CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitmap);
xStart=rand() % GetSystemMetrics(SM_CXSCREEN);
yStart=rand() % GetSystemMetrics(SM_CYSCREEN);
BitBlt(hDC, (short)xStart, (short)yStart, bm.bmWidth, bm.bmHeight,
hMemDC, 0,0, SRCAND);
DeleteDC(hDC);
DeleteDC(hMemDC);
}
break;
case WM_CREATE:
srand((unsigned)GetTickCount());
break;
case WM_DESTROY:
DeleteObject(hBitmap);
PostQuitMessage(0);
break;
default:
return (DefWindowProc(hWnd, iMessage, wParam, lParam));
}
return 0L;
}